WP = waypt_new();
WP->latitude = -pt2deg(wpt->pt.y);
WP->longitude = pt2deg(wpt->pt.x);
- WP->creation_time = unpack_time(wpt->date, wpt->time);
+ WP->SetCreationTime(unpack_time(wpt->date, wpt->time));
for (j=WPT_NAME_LEN-1; j >= 0 && wpt->name[j] == ' '; j--) {};
WP->shortname = xstrndup(wpt->name,j+1);
for (j=WPT_COMMENT_LEN-1; j >= 0 && wpt->comment[j] == ' '; j--) {};
wpt->usecount = isroute ? 1 : 0;
wpt->checked = isroute ? 0 : 1;
wpt->reserved = 0;
- pack_time(WP->creation_time, &(wpt->date), &(wpt->time));
+ pack_time(WP->GetCreationTime(), &(wpt->date), &(wpt->time));
wpthdr->idx[hdr_idx] = wpt_idx;
wpthdr->used[wpt_idx] = WPT_USED;
wpt_tmp = waypt_new();
if (rec->creation_time) {
- wpt_tmp->creation_time = rec->creation_time;
+ wpt_tmp->SetCreationTime(rec->creation_time);
}
wpt_tmp->longitude = -DecodeOrd(rec->lon);
wpt_tmp->latitude = DecodeOrd(rec->lat);
}
- rec->creation_time = rec->modification_time = wpt->creation_time;
+ rec->creation_time = rec->modification_time = wpt->GetCreationTime();
rec->lat = EncodeOrd(wpt->latitude);
rec->lon = EncodeOrd(-wpt->longitude);
rec->serial = serial++;
tm.tm_year-=1900;
tm.tm_mon--;
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
track_add_wpt(track, wpt);
}
case st_sample_alt:
wpt = waypt_new();
wpt->latitude = wpt->longitude = 0.0;
- wpt->creation_time = creation;
+ wpt->SetCreationTime(creation);
creation += interval;
wpt->altitude = (data[0] << 8) + data[1];
track_add_wpt(track, wpt);
rec = (struct cetus_wpt_s*) xcalloc(sizeof(*rec)+18 + NOTESZ + DESCSZ,1);
- QDate date(wpt->creation_time.date());
+ QDate date(wpt->GetCreationTime().date());
rec->day = date.day();
rec->mon = date.month();
be_write16(&rec->year, date.year());
- QTime time(wpt->creation_time.time());
+ QTime time(wpt->GetCreationTime().time());
rec->min = time.minute();
rec->hour = time.hour();
rec->sec = time.second();
strncpy(secString, currentMark->created+13, 2);
secString[2] = '\0';
t.tm_sec = atoi(secString);
- currentMark->wp->creation_time = mkgmtime(&t);
+ currentMark->wp->SetCreationTime(mkgmtime(&t));
}
} else if (inRoute) {
currentRoute->r->rte_name = xstrdup(s);
static char*
ce_gen_creation_time(time_t tm)
{
- xml_fill_in_time(time_buffer, tm, 0, XML_SHORT_TIME);
+ xml_fill_in_time(time_buffer, tm, XML_SHORT_TIME);
return time_buffer;
}
id = xml_buffer;
}
write_xml_entity_begin2(ofd, "\t", "Mark",
- "created", ce_gen_creation_time(wp->creation_time),
+ "created", ce_gen_creation_time(wp->GetCreationTime()),
"id", id);
ce_waypt_pr(wp);
write_xml_entity_end(ofd, "\t", "Mark");
case 5:
if (has_time) {
compegps_parse_time(c, &tm);
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
}
case 6:
wpt->altitude = atof(c);
break;
case 5:
compegps_parse_time(c, &tm);
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
break;
case 7:
wpt->altitude = atof(c);
buff[0] = '\0';
if (wpt->creation_time != 0) {
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
struct tm tm = *gmtime(&tt);
strftime(buff, sizeof(buff), "%d-%b-%y %H:%M:%S", &tm);
rec->time = be_read32(&rec->time);
if (rec->time != 0) {
rec->time -= 2082844800U;
- wpt_tmp->creation_time = rec->time;
+ wpt_tmp->SetCreationTime(rec->time);
}
track_add_wpt(trk_head, wpt_tmp);
}
pow = lrtrim(++pow);
strptime(pow, "%Y %m %d %H:%M:%S", &tm);
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
}
wpt->latitude /= 100000.0;
wpt->longitude /= 100000.0;
/* TIME CONVERSIONS ***************************************************/
case XT_EXCEL_TIME:
/* Time as Excel Time */
- wpt->creation_time = EXCEL_TO_TIMET(atof(s));
+ wpt->SetCreationTime(EXCEL_TO_TIMET(atof(s)));
break;
case XT_TIMET_TIME:
/* Time as time_t */
- wpt->creation_time = (time_t) atol(s);
+ wpt->SetCreationTime((time_t) atol(s));
break;
case XT_TIMET_TIME_MS: {
/* Time as time_t in milliseconds */
int s_len = strlen(s);
if (s_len < 4) {
/* less than 1 epochsecond, an unusual case */
- wpt->creation_time = (time_t) 0;
- wpt->microseconds = (int) atoi(s) * 1000;
+ wpt->SetCreationTime(0,(int) atoi(s) * 1000);
} else {
char buff[32];
int off = s_len - 3;
strncpy(buff, s, off);
buff[off] = '\0';
- wpt->creation_time = (time_t) atol(buff);
+ time_t t = (time_t) atol(buff);
s += off;
strncpy(buff, s, 3);
buff[3] = '\0';
- wpt->microseconds = (int) atoi(buff) * 1000;
+ wpt->SetCreationTime(t, (int) MILLI_TO_MICRO(atoi(buff)));
}
}
break;
case XT_YYYYMMDD_TIME:
- wpt->creation_time = yyyymmdd_to_time(s);
+ wpt->SetCreationTime(yyyymmdd_to_time(s));
break;
case XT_GMT_TIME:
- wpt->creation_time += sscanftime(s, fmp->printfc, 1);
+ wpt->SetCreationTime(sscanftime(s, fmp->printfc, 1));
break;
case XT_LOCAL_TIME:
if (getenv("GPSBABEL_FREEZE_TIME")) {
wpt->creation_time = xml_parse_time(s, &wpt->microseconds);
break;
case XT_NET_TIME: {
- time_t tt = wpt->creation_time;
+ time_t tt = wpt->GetCreationTime();
dotnet_time_to_time_t(atof(s), &tt, &wpt->microseconds);
}
break;
/* TIME CONVERSIONS**************************************************/
case XT_EXCEL_TIME:
/* creation time as an excel (double) time */
- writebuff(buff, fmp->printfc, TIMET_TO_EXCEL(wpt->creation_time));
+ writebuff(buff, fmp->printfc, TIMET_TO_EXCEL(wpt->GetCreationTime()));
break;
case XT_TIMET_TIME:
/* time as a time_t variable */ {
- time_t tt = wpt->creation_time;
+ time_t tt = wpt->GetCreationTime();
writebuff(buff, fmp->printfc, tt); }
break;
case XT_TIMET_TIME_MS: {
/* time as a time_t variable in milliseconds */
char tbuf[24];
- writetime(tbuf, sizeof(tbuf), "%s", wpt->creation_time, 0);
+ writetime(tbuf, sizeof(tbuf), "%s", wpt->GetCreationTime(), 0);
char mbuf[32];
snprintf(mbuf, sizeof(mbuf), "%s%03d", tbuf, wpt->microseconds / 1000);
writebuff(buff, "%s", mbuf);
}
break;
case XT_YYYYMMDD_TIME:
- writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->creation_time));
+ writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->GetCreationTime()));
break;
case XT_GMT_TIME:
- writetime(buff, sizeof buff, fmp->printfc, wpt->creation_time, 1);
+ writetime(buff, sizeof buff, fmp->printfc, wpt->GetCreationTime(), 1);
break;
case XT_LOCAL_TIME:
- writetime(buff, sizeof buff, fmp->printfc, wpt->creation_time, 0);
+ writetime(buff, sizeof buff, fmp->printfc, wpt->GetCreationTime(), 0);
break;
case XT_HMSG_TIME:
- writehms(buff, sizeof buff, fmp->printfc, wpt->creation_time, 1);
+ writehms(buff, sizeof buff, fmp->printfc, wpt->GetCreationTime(), 1);
break;
case XT_HMSL_TIME:
- writehms(buff, sizeof buff, fmp->printfc, wpt->creation_time, 0);
+ writehms(buff, sizeof buff, fmp->printfc, wpt->GetCreationTime(), 0);
break;
case XT_ISO_TIME:
- writetime(buff, sizeof buff, "%Y-%m-%dT%H:%M:%SZ", wpt->creation_time, 1);
+ writetime(buff, sizeof buff, "%Y-%m-%dT%H:%M:%SZ", wpt->GetCreationTime(), 1);
break;
case XT_ISO_TIME_MS:
- xml_fill_in_time(buff, wpt->creation_time,
- wpt->microseconds, XML_LONG_TIME);
+ xml_fill_in_time(buff, wpt->GetCreationTime(), XML_LONG_TIME);
break;
case XT_GEOCACHE_LAST_FOUND:
writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->gc_data->last_found));
session(NULL),
extra_data(NULL) { }
public:
+ QString CreationTimeXML() const;
queue Q; /* Master waypoint q. Not for use
by modules. */
wp_flags wpt_flags;
QString icon_descr;
+
+ gpsbabel::DateTime GetCreationTime() const { return creation_time; }
+ void SetCreationTime(time_t t) { creation_time = t; }
+ void SetCreationTime(time_t t, int us) {
+ creation_time = t;
+ microseconds = us;
+ }
gpsbabel::DateTime creation_time;
int microseconds; /* Optional millionths of a second. */
#define str_iso8859_1_to_utf8(str) cet_str_iso8859_1_to_utf8((str))
/* this lives in gpx.c */
-time_t xml_parse_time(const char* cdatastr, int* microsecs);
+gpsbabel::DateTime xml_parse_time(const char* cdatastr, int* microsecs);
xml_tag* xml_findfirst(xml_tag* root, const char* tagname);
xml_tag* xml_findnext(xml_tag* root, xml_tag* cur, const char* tagname);
const char* s;
float f;
- wp->creation_time = decode_time(&p->year);
+ wp->SetCreationTime(decode_time(&p->year));
wp->latitude = delbin_rad2deg(le_read32(p->latitude));
wp->longitude = delbin_rad2deg(le_read32(p->longitude));
f = le_read_float(p->elevation);
waypoint_i++;
le_write32(p->total, waypoint_n);
le_write32(p->index, waypoint_i);
- encode_time(wp->creation_time, &p->year);
+ encode_time(wp->GetCreationTime(), &p->year);
le_write32(p->latitude, delbin_deg2rad(wp->latitude));
le_write32(p->longitude, delbin_deg2rad(wp->longitude));
if (wp->altitude > unknown_alt) {
waypoint* wp = waypt_new();
float elev = le_read_float(p->point[i].elevation);
wp_array[j] = wp;
- wp->creation_time = decode_time(&p->point[i].year);
+ wp->SetCreationTime(decode_time(&p->point[i].year));
wp->latitude = delbin_rad2deg(le_read32(p->point[i].latitude));
wp->longitude = delbin_rad2deg(le_read32(p->point[i].longitude));
if (elev > UNKNOWN_ELEV) {
le_write32(p->index, i + 1);
}
assert(p);
- encode_time(wp->creation_time, &p->point[j].year);
+ encode_time(wp->GetCreationTime(), &p->point[j].year);
le_write32(p->point[j].latitude, delbin_deg2rad(wp->latitude));
le_write32(p->point[j].longitude, delbin_deg2rad(wp->longitude));
f = UNKNOWN_ELEV;
if (track->rte_name) {
strncpy(p->name, track->rte_name, sizeof(p->name) - 1);
} else {
- sprintf(p->name, "%lu", (long)wp_array[0]->creation_time);
+ sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime());
}
le_write32(p->total_points, waypoint_n);
encode_time(current_time(), &p->year);
if (route->rte_name) {
strncpy(p->name, route->rte_name, sizeof(p->name) - 1);
} else {
- sprintf(p->name, "%lu", (long)wp_array[0]->creation_time);
+ sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime());
}
p->type = 0;
le_write32(p->total_route_point, route_point_n);
t.tm_hour = p->hour;
t.tm_min = p->minute;
t.tm_sec = p->second;
- wp->creation_time = mkgmtime(&t);
+ wp->SetCreationTime(mkgmtime(&t));
wp->sat = p->satellites;
wp->latitude = le_read_double(p->latitude);
wp->longitude = le_read_double(p->longitude);
if (wpt_tmp->altitude <= unknown_alt + 1) {
wpt_tmp->altitude = unknown_alt;
}
- wpt_tmp->creation_time = le_read32(&gp.tm);
+ wpt_tmp->SetCreationTime(le_read32(&gp.tm));
switch (le_read32(&gp.status)) {
case 1:
le_write_double(&gp.alt, alt_feet);
le_write_double(&gp.speed, speed);
le_write_double(&gp.heading, heading);
- le_write32(&gp.tm, wpt->creation_time);
+ le_write32(&gp.tm, wpt->GetCreationTime());
gbfwrite(&gp, sizeof(gp), 1, gplfile_out);
}
snprintf(buff, sizeof(buff), "%06d%.f", date, time);
strptime(buff, "%d%m%y%H%M%S", &tm);
- wpt->creation_time = mkgmtime(&tm);
- wpt->microseconds = ((int)time % 1000) * 1000;
+ wpt->SetCreationTime(mkgmtime(&tm),
+ ((int)time % 1000) * 1000);
if (wpt->fix > 0) {
wpt->fix = (fix_type)(wpt->fix + 1);
struct tm tm;
double time;
int date;
- const time_t ct = wpt->creation_time;
+ const time_t ct = wpt->GetCreationTime();
tm = *gmtime(&ct);
tm.tm_mon += 1;
tm.tm_year -= 100;
if (style >= 1) {
bintime = be_read32(data + i + 8) & 0x7FFFFFFF;
bindate = be_read32(data + i + 12);
- wpt->creation_time = bintime2utc(bindate, bintime);
+ wpt->SetCreationTime(bintime2utc(bindate, bintime));
/* The device presents the speed as a fixed-point number
* with a scaling factor of 100, in km/h.
* The waypoint struct wants the speed as a
struct tm tm;
char buf[32];
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = *gmtime(&tt);
tm.tm_year += 1900;
if (cerr == NULL) {
fatal(MYNAME ": Unable to convert date (%s)!\n", cin);
}
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
break;
case WAYPT__OFS + 1:
if (cerr == NULL) {
fatal(MYNAME ": Unable to convert date (%s)!\n", buff);
}
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
/* go over time stamp */
i = 5;
wpt->longitude = gps_save_lon;
wpt->shortname = xstrdup("Position");
if (gps_save_time) {
- wpt->creation_time = gps_save_time;
+ wpt->SetCreationTime(gps_save_time);
}
waypt_add(wpt);
return;
wpt_tmp->altitude = way[i]->alt;
}
if (way[i]->time_populated) {
- wpt_tmp->creation_time = way[i]->time;
+ wpt_tmp->SetCreationTime(way[i]->time);
}
#if SOON
garmin_fs_garmin_after_read(way[i], wpt_tmp, gps_waypt_type);
int i;
for (i=(nlaps-1); i >= 0; i--) {
GPS_PLap lap = laps[i];
- time_t delta = lap->start_time - wpt->creation_time;
+ time_t delta = lap->start_time - wpt->GetCreationTime();
if ((delta >= -1) && (delta <= 1)) {
result = 1;
break;
wpt->heartrate = array[i]->heartrate;
wpt->cadence = array[i]->cadence;
wpt->shortname = xstrdup(array[i]->trk_ident);
- wpt->creation_time = array[i]->Time;
+ wpt->SetCreationTime(array[i]->Time);
wpt->wpt_flags.is_split = checkWayPointIsAtSplit(wpt, laps,
nlaps);
wpt->wpt_flags.new_trkseg = next_is_new_trkseg;
tx_waylist[i]->alt = wpt->altitude;
}
if (wpt->creation_time) {
- tx_waylist[i]->time = wpt->creation_time;
+ tx_waylist[i]->time = wpt->GetCreationTime();
tx_waylist[i]->time_populated = 1;
}
if (category) {
indent, waypointp->altitude);
}
if (waypointp->creation_time) {
- xml_write_time(ofd, waypointp->creation_time, waypointp->microseconds, "time");
+ xml_write_time(ofd, waypointp->GetCreationTime(), waypointp->microseconds, "time");
}
}
waypoint* prev = cur_info->prev_wpt;
if (prev != NULL) {
- cur_info->time += (wpt->creation_time - prev->creation_time);
+ cur_info->time += (wpt->GetCreationTime() - prev->GetCreationTime());
cur_info->length += waypt_distance_ex(prev, wpt);
} else {
cur_info->first_wpt = (waypoint*)wpt;
- cur_info->start = wpt->creation_time;
+ cur_info->start = wpt->GetCreationTime();
}
cur_info->prev_wpt = (waypoint*)wpt;
cur_info->count++;
print_string("%s\t", GMSD_GET(state, ""));
country = gt_get_icao_country(GMSD_GET(cc, ""));
print_string("%s\t", (country != NULL) ? country : "");
- print_date_and_time(wpt->creation_time, 0);
+ print_date_and_time(wpt->GetCreationTime(), 0);
print_string("%s\t", wpt->hasLink() ? wpt->url : "");
print_categories(GMSD_GET(category, 0));
gbfprintf(fout, "Trackpoint\t");
print_position(wpt);
- print_date_and_time(wpt->creation_time, 0);
+ print_date_and_time(wpt->GetCreationTime(), 0);
if IS_VALID_ALT(wpt->altitude) {
print_distance(wpt->altitude, 1, 0, 0);
}
if (prev != NULL) {
float temp;
gbfprintf(fout, "\t");
- delta = wpt->creation_time - prev->creation_time;
+ delta = wpt->GetCreationTime() - prev->GetCreationTime();
temp = WAYPT_GET(wpt, temperature, -999);
if (temp != -999) {
print_temperature(temp);
wpt->latitude = PrevLat; /* Degrees */
wpt->longitude = PrevLon; /* Degrees */
wpt->altitude = PrevEle; /* Meters. */
- wpt->creation_time = Time; /* Unix Time adjusted to Garmin time */
+ wpt->SetCreationTime(Time); /* Unix Time adjusted to Garmin time */
// add way point to the track
track_add_wpt(tmp_track, wpt);
wpt->latitude = PrevLat; /* Degrees */
wpt->longitude = PrevLon; /* Degrees */
wpt->altitude = PrevEle; /* Meters. */
- wpt->creation_time = Time; /* Unix Time adjusted to Garmin time */
+ wpt->SetCreationTime(Time); /* Unix Time adjusted to Garmin time */
// add way point to the track
track_add_wpt(tmp_track, wpt);
wpt->latitude = LatF*180/16777216; /* Degrees */
wpt->longitude = LonF*360/16777216; /* Degrees */
wpt->altitude = AltF; /* Meters. */
- wpt->creation_time = Tim; /* Unix Time adjusted to Garmin time */
+ wpt->SetCreationTime(Tim); /* Unix Time adjusted to Garmin time */
track_add_wpt(track, wpt);
}
time_t tm;
tm = be_read32(recdata) * 24 * 3600;
tm -= EPOCH_1904;
-wpt->creation_time = tm;
+wpt->SetCreationTime(tm);
warning("date %d\n", tm);
}
break;
* not the cache creation date.
*/
if (wpt->creation_time) {
-gcdb_add_to_rec(rec, "date", RECTYPE_DATE, (void*) wpt->creation_time);
+gcdb_add_to_rec(rec, "date", RECTYPE_DATE, (void*) wpt->GetCreationTime());
}
#endif
FWRITE_i16(GMSD_GET(category, gdb_category));
FWRITE_DBL(WAYPT_GET(wpt, temperature, 0), 0);
- FWRITE_TIME(wpt->creation_time);
+ FWRITE_TIME(wpt->GetCreationTime());
/* VERSION DEPENDENT CODE */
if (gdb_ver >= GDB_VER_3) {
FWRITE_LATLON(wpt->latitude);
FWRITE_LATLON(wpt->longitude);
FWRITE_DBL(wpt->altitude, unknown_alt);
- FWRITE_TIME(wpt->creation_time);
+ FWRITE_TIME(wpt->GetCreationTime());
d = WAYPT_GET(wpt, depth, unknown_alt);
FWRITE_DBL(d, unknown_alt);
d = WAYPT_GET(wpt, temperature, -99999);
tm.tm_year -= 1900;
sscanf(timestr, "%d:%d:%d", &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
if (tm.tm_year >= 1970) {
- wpt->creation_time = mktime(&tm);
+ wpt->SetCreationTime(mktime(&tm));
}
xfree(datestr);
xfree(timestr);
waypt->shortname = xstrdup(vdata + 63);
waypt->altitude = altitude;
- waypt->creation_time = mkgmtime(&created);
+ waypt->SetCreationTime(mkgmtime(&created));
GPS_Math_DegMin_To_Deg(latdeg, lat, &waypt->latitude);
GPS_Math_DegMin_To_Deg(londeg, lon, &waypt->longitude);
id = rec_ct;
}
- tx = (wpt->creation_time != 0) ? wpt->creation_time : gpsbabel_time;
+ tx = (wpt->GetCreationTime() != 0) ? wpt->GetCreationTime() : gpsbabel_time;
if (tx == 0) { /* maybe zero during testo (freezed time) */
strcpy(datestr, "01/01/1904"); /* this seems to be the uninitialized date value for geoniche */
strcpy(timestr, "00:00:00");
tm.tm_year -= 1900;
if (tm.tm_mon > 0) {
tm.tm_mon--;
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
}
}
lonsec = 60.0 * (lonmin - floor(lonmin));
if (wpt->creation_time > 0) {
- tm = *gmtime(&wpt->creation_time);
+ tm = *gmtime(&wpt->GetCreationTime());
tm.tm_mon += 1;
tm.tm_year += 1900;
} else {
}
gbfprintf(ofd, " </Position>\n");
gbfprintf(ofd, " ");
- xml_write_time(ofd, wpt->creation_time, wpt->microseconds, "Time");
+ xml_write_time(ofd, wpt->GetCreationTime(), wpt->microseconds, "Time");
gbfprintf(ofd, " </Trackpoint>\n");
}
void gl_trk_utc(const char* args, const char** unused)
{
- wpt_tmp->creation_time = xml_parse_time(args, &wpt_tmp->microseconds);
+ wpt_tmp->SetCreationTime(xml_parse_time(args, &wpt_tmp->microseconds));
}
void gl_trk_lat(const char* args, const char** unused)
wpt = waypt_new();
- wpt->creation_time = le_read32(&rec.time);
+ wpt->SetCreationTime(le_read32(&rec.time));
wpt->latitude = le_read_float(&rec.lat);
wpt->longitude = le_read_float(&rec.lon);
wpt->altitude = read_altitude(&rec.alt);
{
gnav_trl_t rec;
- le_write32(&rec.time, wpt->creation_time);
+ le_write32(&rec.time, wpt->GetCreationTime());
le_write_float(&rec.lat, wpt->latitude);
le_write_float(&rec.lon, wpt->longitude);
if (wpt->altitude != unknown_alt) {
//calculate the speed to reach this waypoint from the last. This way I try to sort out invalid waypoints
speed=0;
if (lastwpt !=NULL) {
- speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) / abs(wpt->creation_time - lastwpt->creation_time);
+ speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) / abs(wpt->creation_time - lastwpt->GetCreationTime());
//printf("speed line %d %lf \n",line,speed);
}
/* Error handling: in the tracklog of my device sometimes "jump" waypoints ;-) */
}
}
//MSVC handles time_t as int64, gcc and mac only int32, so convert it:
- timestamp=(unsigned long)wpt->creation_time;
+ timestamp=(unsigned long)wpt->GetCreationTime();
gbfprintf(fout, "%lu, %s, %lf, %lf, %5.1lf, %8.5lf, %d, %lf, %d\n",timestamp,tbuffer, wpt->longitude, wpt->latitude,wpt->altitude,
wpt->speed,fix,wpt->hdop,wpt->sat);
}
* Garmin/GPilotS count seconds from "UTC 12:00 AM December 31 1989".
* gpsbabel counts seconds from "UTC 12:00 AM January 1 1970".
*/
- wpt_tmp->creation_time = be_read32(&tp_cust->time) + 631065600;
+ wpt_tmp->SetCreationTime(be_read32(&tp_cust->time) + 631065600);
fi.i = be_read32(&tp_cust->alt);
wpt_tmp->altitude = fi.f;
track_add_wpt(track_head, wpt_tmp);
int hms, ymd;
struct tm* tm;
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = gmtime(&tt);
hms = tm->tm_hour * 10000 + tm->tm_min * 100 + tm->tm_sec;
ymd = tm->tm_mday * 10000 + tm->tm_mon * 100 + tm->tm_year;
wpt_tmp->altitude = alt;
wpt_tmp->shortname = sn;
wpt_tmp->description = xstrdup(desc);
- wpt_tmp->creation_time = now;
+ wpt_tmp->SetCreationTime(now);
if (latdir == 'S') {
lat = -lat;
#include <QtCore/QRegExp>
//#include <QtCore/QTextCodec>
#include <QtXml/QXmlStreamAttributes>
+#include <QtCore/QDebug>
static xml_tag* cur_tag;
return "Unknown";
}
-time_t
+gpsbabel::DateTime
xml_parse_time(const char* cdatastr, int* microsecs)
{
int off_hr = 0;
xfree(timestr);
- return rv;
+ // TOOD(robertlipe) - This really is a groady hack to shim in
+ // the old interface (which had an explicit microsecs pointer argument
+ // as an optional output value) and the new form which uses QDateTime
+ // but, because of the above hackery, doesn't really work outside 1970
+ // 2038 but which we can't replace until Steven upgrades Qt.
+ // Baby steps.
+ QDateTime dt = QDateTime::fromTime_t(rv);
+ if (microsecs) {
+ dt = dt.addMSecs(*microsecs / 1000);
+// qDebug() << dt.toString("dd.MM.yyyy hh:mm:ss.zzz") << " ZZZ " << *microsecs;
+ }
+ return dt;
}
static void
case tt_wpt_time:
case tt_trk_trkseg_trkpt_time:
case tt_rte_rtept_time:
- wpt_tmp->creation_time = xml_parse_time(cdatastrp, &wpt_tmp->microseconds);
+ wpt_tmp->SetCreationTime(xml_parse_time(cdatastrp, &wpt_tmp->microseconds));
break;
case tt_wpt_cmt:
case tt_rte_rtept_cmt:
strcmp(tag->tagname, "groundspeak:cache") == 0) {
char time_string[64];
xml_fill_in_time(time_string, wpt->gc_data->exported,
- 0, XML_LONG_TIME);
+ XML_LONG_TIME);
if (time_string[0]) {
writer.writeTextElement("time", time_string);
}
if (waypointp->altitude != unknown_alt) {
writer.writeTextElement("ele", QString::number(waypointp->altitude, 'f', 6));
}
- if (waypointp->creation_time) {
- char time_string[64];
- // FIXME: Eventually use creation_time.toString()
- xml_fill_in_time(time_string, waypointp->creation_time,
- waypointp->microseconds, XML_LONG_TIME);
- if (time_string[0]) {
- writer.writeTextElement("time", time_string);
- }
- }
+ QString t = waypointp->CreationTimeXML();
+ writer.writeOptionalTextElement("time", t);
}
static void
now = current_time();
char time_string[64];
- xml_fill_in_time(time_string, now, 0, XML_LONG_TIME);
+ xml_fill_in_time(time_string, now, XML_LONG_TIME);
if (time_string[0]) {
writer.writeTextElement("time", time_string);
}
fwrite_integer(file_out, icon_from_descr(wpt->icon_descr));
fwrite_byte(file_out, 3);
if (wpt->creation_time) {
- fwrite_long(file_out, wpt->creation_time-EPOCH89DIFF);
+ fwrite_long(file_out, wpt->GetCreationTime()-EPOCH89DIFF);
} else {
fwrite_long(file_out, 0);
}
{
fwrite_double(file_out, wpt->latitude);
fwrite_double(file_out, wpt->longitude);
- fwrite_long(file_out, wpt->creation_time-EPOCH89DIFF);
+ fwrite_long(file_out, wpt->GetCreationTime()-EPOCH89DIFF);
fwrite_byte(file_out, start_new);
if (wpt->altitude == unknown_alt) {
fwrite_single(file_out, unknown_alt_gtm);
gtc_study_lap(const waypoint* wpt)
{
if (wpt->creation_time && (gtc_least_time == 0)) {
- gtc_least_time = wpt->creation_time;
+ gtc_least_time = wpt->GetCreationTime();
gtc_start_lat = wpt->latitude;
gtc_start_long = wpt->longitude;
}
- if (wpt->creation_time && (gtc_least_time > wpt->creation_time)) {
- gtc_least_time = wpt->creation_time;
+ if (wpt->creation_time && (gtc_least_time > wpt->GetCreationTime())) {
+ gtc_least_time = wpt->GetCreationTime();
gtc_start_lat = wpt->latitude;
gtc_start_long = wpt->longitude;
}
if (wpt->creation_time > gtc_most_time) {
- gtc_most_time = wpt->creation_time;
+ gtc_most_time = wpt->GetCreationTime();
gtc_end_lat = wpt->latitude;
gtc_end_long = wpt->longitude;
}
}
if (wpt->creation_time) {
- char time_string[100];
- xml_fill_in_time(time_string, wpt->creation_time, wpt->microseconds,
- XML_LONG_TIME);
- if (time_string[0]) {
+ QString time_string = wpt->CreationTimeXML();
+ if (!time_string.isEmpty()) {
gtc_write_xml(0, "<Time>%s</Time>\n",
- time_string);
+ qPrintable(time_string));
}
}
if (wpt->latitude && wpt->longitude) {
route_disp(rte, gtc_study_lap);
if (gtc_least_time) {
char time_string[100];
- xml_fill_in_time(time_string, gtc_least_time, 0, XML_LONG_TIME);
+ xml_fill_in_time(time_string, gtc_least_time, XML_LONG_TIME);
gtc_write_xml(0, "<Id>%s</Id>\n", time_string);
gtc_write_xml(1, "<Lap StartTime=\"%s\">\n", time_string);
} else {
{
gbfprintf(ofd, " <pnt>\n");
if (waypointp->creation_time) {
- hiketech_print_utc(waypointp->creation_time, " ", "utc");
+ hiketech_print_utc(waypointp->GetCreationTime(), " ", "utc");
}
gbfprintf(ofd, " <lat>%f</lat>\n", waypointp->latitude);
gbfprintf(ofd, " <long>%f</long>\n", waypointp->longitude);
utc = mkgmtime(&tm);
- wpt_tmp->creation_time = utc;
+ wpt_tmp->SetCreationTime(utc);
}
static
wpt_tmp->shortname = xstrdup(name);
wpt_tmp->description = xstrdup(desc);
- wpt_tmp->creation_time = 0;
+ wpt_tmp->SetCreationTime(0);
if (pWptHxTmp->date.year) {
#if 0
/* Unless there's some endian swapping that I don't see,
tm.tm_mday = pWptHxTmp->date.day;
tm.tm_mon = pWptHxTmp->date.month - 1;
tm.tm_year = pWptHxTmp->date.year - 1900;
- wpt_tmp->creation_time = mktime(&tm);
+ wpt_tmp->SetCreationTime(mktime(&tm));
}
lon = le_read32(&pWptHxTmp->pt.iLongitude) / 36000.0;
/*set the time */
if (wpt->creation_time) {
/* tm = gmtime(&wpt->creation_time);*/ /* I get the wrong result with gmtime ??? */
- QDate date(wpt->creation_time.date());
- QTime time(wpt->creation_time.time());
+ QDate date(wpt->GetCreationTime().date());
+ QTime time(wpt->GetCreationTime().time());
pWptHxTmp->time = (time.hour() * 3600) + (time.minute()* 60) + time.second();
pWptHxTmp->date.day = date.day();
pWptHxTmp->date.month = date.month();
} else if (strcmp(el, "Longitude") == 0) {
wpt_tmp->longitude = atof(cdatastr);
} else if (strcmp(el, "Time") == 0) {
- wpt_tmp->creation_time = atoi(cdatastr);
+ wpt_tmp->SetCreationTime(atoi(cdatastr));
}
}
}
{
char tbuf[1024];
char* cout;
- time_t tm = wpt->creation_time;
+ time_t tm = wpt->GetCreationTime();
gbint32 utmz;
double utme, utmn;
char utmzc;
wpt = waypt_new();
wpt->shortname = xstrndup(w.name, sizeof(w.name));
- wpt->creation_time = w.time;
+ wpt->SetCreationTime(w.time);
guder = gudermannian_i1924(w.north);
wpt->latitude = geocentric_to_geodetic_hwr(guder);
/* Unless it's zero. Sometimes happens, possibly if
the gps didn't have a lock when the track was
saved. */
- wpt->creation_time = th.time;
+ wpt->SetCreationTime(th.time);
}
track_add_wpt(trk, wpt);
}
/* Unless it's zero. Sometimes happens, possibly if
the gps didn't have a lock when the track was
saved. */
- wpt->creation_time = th.time;
+ wpt->SetCreationTime(th.time);
}
track_add_wpt(trk, wpt);
}
hum.depth = si_round(WAYPT_GET(wpt, depth, 0)*100.0);
be_write16(&hum.depth, hum.depth);
- be_write32(&hum.time, wpt->creation_time);
+ be_write32(&hum.time, wpt->GetCreationTime());
east = wpt->longitude / 180.0 * EAST_SCALE;
be_write32(&hum.east, si_round((east)));
north = si_round(inverse_gudermannian_i1924(lat));
if (wpt->creation_time != 0) {
- last_time = wpt->creation_time;
+ last_time = wpt->GetCreationTime();
}
if (i == 0) {
wpt->longitude = ('E' == lon_hemi[0] ? 1 : -1) *
(lon_deg + (lon_min * 1000 + lon_frac) / 1000.0 / 60);
- wpt->creation_time = creation;
+ wpt->SetCreationTime(creation);
wpt->description = xstrdup(tmp_str);
// Name the waypoint according to the order of the task record
date += 24 * 60 * 60;
}
prev_tod = tod;
- pres_wpt->creation_time = date + tod;
+ pres_wpt->SetCreationTime(date + tod);
// Add the waypoint to the pressure altitude track
if (pres_alt) {
}
// Date in header record is that of the first fix record
date = !track ? current_time() :
- ((waypoint*) QUEUE_FIRST(&track->waypoint_list))->creation_time;
+ ((waypoint*) QUEUE_FIRST(&track->waypoint_list))->GetCreationTime();
if (NULL == (tm = gmtime(&date))) {
fatal(MYNAME ": Bad track timestamp\n");
fatal(MYNAME ": Too much waypoints (more than 99) in task route.\n");
}
// Gather data to write to the task identification (first) record
- rte_time = wpt->creation_time ? wpt->creation_time : current_time();
+ rte_time = wpt->GetCreationTime() ? wpt->GetCreationTime() : current_time();
if (NULL == (tm = gmtime(&rte_time))) {
fatal(MYNAME ": Bad task route timestamp\n");
}
{
struct tm* tm;
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = gmtime(&tt);
if (NULL == tm) {
return 0;
}
} while (alt_diff > -10.0);
- pres_time = ((waypoint*) elem->next)->creation_time;
+ pres_time = ((waypoint*) elem->next)->GetCreationTime();
if (global_opts.debug_level >= 1) {
printf(MYNAME ": pressure landing time %s", ctime(&pres_time));
}
return 0;
}
// Get a crude indication of groundspeed from the change in lat/lon
- time_diff = wpt->creation_time - ((waypoint*) elem)->creation_time;
+ time_diff = wpt->GetCreationTime() - ((waypoint*) elem)->GetCreationTime();
speed = !time_diff ? 0 :
(fabs(wpt->latitude - ((waypoint*) elem)->latitude) +
fabs(wpt->longitude - ((waypoint*) elem)->longitude)) / time_diff;
printf(MYNAME ": speed=%f\n", speed);
}
} while (speed < 0.00003);
- gnss_time = ((waypoint*) elem->next)->creation_time;
+ gnss_time = ((waypoint*) elem->next)->GetCreationTime();
if (global_opts.debug_level >= 1) {
printf(MYNAME ": gnss landing time %s", ctime(&gnss_time));
}
curr_elem = prev_elem = QUEUE_FIRST(&track->waypoint_list);
}
// Find the track points either side of the requested time
- while (((waypoint*) curr_elem)->creation_time < time) {
+ while (((waypoint*) curr_elem)->GetCreationTime() < time) {
if (QUEUE_LAST(&track->waypoint_list) == curr_elem) {
// Requested time later than all track points, we can't interpolate
return unknown_alt;
curr_wpt = (waypoint*) curr_elem;
if (QUEUE_FIRST(&track->waypoint_list) == curr_elem) {
- if (curr_wpt->creation_time == time) {
+ if (curr_wpt->GetCreationTime() == time) {
// First point's creation time is an exact match so use it's altitude
return curr_wpt->altitude;
} else {
}
}
// Interpolate
- if (0 == (time_diff = curr_wpt->creation_time - prev_wpt->creation_time)) {
+ if (0 == (time_diff = curr_wpt->GetCreationTime() - prev_wpt->GetCreationTime())) {
// Avoid divide by zero
return curr_wpt->altitude;
}
alt_diff = curr_wpt->altitude - prev_wpt->altitude;
- return prev_wpt->altitude + (alt_diff / time_diff) * (time - prev_wpt->creation_time);
+ return prev_wpt->altitude + (alt_diff / time_diff) * (time - prev_wpt->GetCreationTime());
}
/*
// Iterate through waypoints in both tracks simultaneously
QUEUE_FOR_EACH(&gnss_track->waypoint_list, elem, tmp) {
wpt = (waypoint*) elem;
- pres_alt = interpolate_alt(pres_track, wpt->creation_time + time_adj);
+ pres_alt = interpolate_alt(pres_track, wpt->GetCreationTime() + time_adj);
wr_fix_record(wpt, (int) pres_alt, (int) wpt->altitude);
}
} else {
if (wpt->creation_time == 0) {
le_write32(&point.unix_time, invented_time++);
} else {
- le_write32(&point.unix_time, wpt->creation_time);
+ le_write32(&point.unix_time, wpt->GetCreationTime());
}
// Write the first part of the Information Block, the start time
wpt->latitude = lat;
wpt->longitude = lon;
- wpt->creation_time = time;
- wpt->microseconds = micros;
+ wpt->SetCreationTime(time, micros);
if (speed >= 0) {
WAYPT_SET(wpt, speed, speed);
}
struct tm tm;
if (wpt->creation_time > 0) {
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = *gmtime(&tt);
tm.tm_year += 1900;
static int realtime_positioning;
static bounds kml_bounds;
-static time_t kml_time_min;
-static time_t kml_time_max;
+static gpsbabel::DateTime kml_time_min;
+static gpsbabel::DateTime kml_time_max;
#define AUTOFORMATTING_OFF(AF) bool AF=writer->autoFormatting(); writer->setAutoFormatting(false);
#define AUTOFORMATTING_RESTORE(AF) writer->setAutoFormatting(af);
static void kml_output_timestamp(const waypoint* waypointp)
{
- if (waypointp->creation_time) {
- char time_string[64];
- xml_fill_in_time(time_string, waypointp->creation_time, waypointp->microseconds, XML_LONG_TIME);
- if (time_string[0]) {
- writer->writeStartElement("TimeStamp");
- AUTOFORMATTING_OFF(af); // FIXME: we turn off autoformatting just to match old writer test references.
- writer->writeTextElement("when", time_string);
- writer->writeEndElement(); // Close TimeStamp tag
- AUTOFORMATTING_RESTORE(af);
- }
+ QString time_string = waypointp->CreationTimeXML();
+ if(!time_string.isEmpty()) {
+ writer->writeStartElement("TimeStamp");
+ AUTOFORMATTING_OFF(af); // FIXME: we turn off autoformatting just to match old writer test references.
+ writer->writeTextElement("when", time_string);
+ writer->writeEndElement(); // Close TimeStamp tag
+ AUTOFORMATTING_RESTORE(af);
}
}
if (td->start && td->end) {
char time_string[64];
- xml_fill_in_time(time_string, td->start, 0, XML_LONG_TIME);
+ xml_fill_in_time(time_string, td->start, XML_LONG_TIME);
kml_td(hwriter, "Start Time", QString(" %1 ").arg(time_string));
- xml_fill_in_time(time_string, td->end, 0, XML_LONG_TIME);
+ xml_fill_in_time(time_string, td->end, XML_LONG_TIME);
kml_td(hwriter, "End Time", QString(" %1 ").arg(time_string));
}
if (td->start && td->end) {
char time_string[64];
writer->writeStartElement("TimeSpan");
- xml_fill_in_time(time_string, td->start, 0, XML_LONG_TIME);
+ xml_fill_in_time(time_string, td->start, XML_LONG_TIME);
writer->writeTextElement("begin", time_string);
- xml_fill_in_time(time_string, td->end, 0, XML_LONG_TIME);
+ xml_fill_in_time(time_string, td->end, XML_LONG_TIME);
writer->writeTextElement("end", time_string);
writer->writeEndElement(); // Close TimeSpan tag
}
/* This really shouldn't be here, but as of this writing,
* Earth can't edit/display the TimeStamp.
*/
- if (pt->creation_time) {
- char time_string[64];
-
- xml_fill_in_time(time_string, pt->creation_time,
- pt->microseconds, XML_LONG_TIME);
- if (time_string[0]) {
- kml_td(hwriter, QString("Time: %1 ").arg(time_string));
+ if (pt->GetCreationTime()) {
+ QString time_string = pt->CreationTimeXML();
+ if(!time_string.isEmpty()) {
+ kml_td(hwriter, QString("Time: %1 ").arg(time_string));
}
}
static void kml_recompute_time_bounds(const waypoint* waypointp)
{
- if (waypointp->creation_time && (waypointp->creation_time < kml_time_min)) {
- kml_time_min = waypointp->creation_time;
+ if (waypointp->GetCreationTime() && (waypointp->GetCreationTime() < kml_time_min)) {
+ kml_time_min = waypointp->GetCreationTime();
}
- if (waypointp->creation_time > kml_time_max) {
- kml_time_max = waypointp->creation_time;
+ if (waypointp->GetCreationTime() > kml_time_max) {
+ kml_time_max = waypointp->GetCreationTime();
if (kml_time_min == 0) {
- kml_time_min = waypointp->creation_time;
+ kml_time_min = waypointp->GetCreationTime();
}
}
}
kml_output_timestamp(waypointp);
if (waypointp->creation_time) {
strcpy(date_placed,
- qPrintable(waypointp->creation_time.toString("dd-MMM-yyyy")));
+ qPrintable(waypointp->GetCreationTime().toString("dd-MMM-yyyy")));
} else {
date_placed[0] = '\0';
}
QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
waypoint* tpt = (waypoint*)elem;
- if (tpt->creation_time) {
- char time_string[64];
- xml_fill_in_time(time_string, tpt->creation_time, tpt->microseconds,
- XML_LONG_TIME);
- if (time_string[0]) {
- writer->writeTextElement("when", time_string);
- }
+ if (tpt->GetCreationTime()) {
+ QString time_string = tpt->CreationTimeXML();
+ writer->writeOptionalTextElement("when", time_string);
} else {
writer->writeStartElement("when");
writer->writeEndElement(); // Close when tag
writer->writeStartElement("gx:TimeSpan");
if (kml_time_min) {
char time_string[64];
- xml_fill_in_time(time_string, kml_time_min, 0, XML_LONG_TIME);
+ xml_fill_in_time(time_string, kml_time_min, XML_LONG_TIME);
if (time_string[0]) {
writer->writeTextElement("begin", time_string);
}
// ensure the right edge of that time slider includes us.
//
time_max = realtime_positioning ? kml_time_max + 600 : kml_time_max;
- xml_fill_in_time(time_string, time_max, 0, XML_LONG_TIME);
+ xml_fill_in_time(time_string, time_max, XML_LONG_TIME);
if (time_string[0]) {
writer->writeTextElement("end", time_string);
}
static void
kml_wr_position(waypoint* wpt)
{
- static time_t last_valid_fix;
+ static gpsbabel::DateTime last_valid_fix;
kml_wr_init(posnfilenametmp);
case fix_unknown:
break;
default:
- last_valid_fix = wpt->creation_time;
+ last_valid_fix = wpt->GetCreationTime();
}
- wpt->icon_descr = kml_get_posn_icon(wpt->creation_time - last_valid_fix);
+ wpt->icon_descr = kml_get_posn_icon(wpt->GetCreationTime() - last_valid_fix);
/* In order to avoid clutter while we're sitting still, don't add
dmy = dmy / 100;
tm.tm_mday = dmy % 100;
- waypt->creation_time = mkgmtime(&tm);
- waypt->microseconds = CENTI_TO_MICRO(fracsecs);
+ waypt->SetCreationTime(mkgmtime(&tm), CENTI_TO_MICRO(fracsecs));
if (latdir == 'S') {
latdeg = -latdeg;
ilon = waypointp->longitude;
tm = NULL;
if (waypointp->creation_time) {
- const time_t ct = waypointp->creation_time;
+ const time_t ct = waypointp->GetCreationTime();
tm = gmtime(&ct);
if (tm) {
hms = tm->tm_hour * 10000 + tm->tm_min * 100 +
mapsend_read(void)
{
mapsend_hdr hdr;
- int type, len;
+ int type;
+ gbsize_t len;
char buf[3];
/*
void mapsend_track_disp(const waypoint* wpt)
{
unsigned char c;
- int t;
+ gbint32 t;
static int last_time;
/*
*
* This is rumoured (but yet unconfirmed) to be fixed in f/w 5.12.
*/
- t = wpt->creation_time;
+ t = wpt->GetCreationTime();
if (t < last_time) {
t = last_time;
}
QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
testwpt = (waypoint*)elem;
if (rte_datapoints == 0) {
- uniqueValue = testwpt->creation_time;
+ uniqueValue = testwpt->GetCreationTime();
}
if (testwpt->latitude > maxlat) {
maxlat = testwpt->latitude;
thisWaypoint = waypt_new();
thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat);
thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon);
- thisWaypoint->creation_time = dateTime;
- thisWaypoint->microseconds = 0;
+ thisWaypoint->SetCreationTime(dateTime);
thisWaypoint->altitude = mps_altitude;
if (mps_depth != unknown_alt) {
WAYPT_SET(thisWaypoint, depth, mps_depth);
QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
if (trk_datapoints == 0) {
testwpt = (waypoint*)elem;
- uniqueValue = testwpt->creation_time;
+ uniqueValue = testwpt->GetCreationTime();
}
trk_datapoints++;
}
mps_trackdatapoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt)
{
int lat, lon;
- time_t t = wpt->creation_time;
+ time_t t = wpt->GetCreationTime();
char zbuf[10];
double mps_altitude = wpt->altitude;
time = data->ctime;
}
if (time > 0) {
- wpt->creation_time = time;
+ wpt->SetCreationTime(time);
}
if (mmo_version >= 0x18) {
unk = gbfgetc(fin);
DBG((sobj, "Unknown = 0x%02X (%d)\n", unk, unk));
- wpt->creation_time = gbfgetint32(fin);
+ wpt->SetCreationTime(gbfgetint32(fin));
wpt->altitude = gbfgetflt(fin);
if (unk != 0) {
if (global_opts.masked_objective & TRKDATAMASK) {
trkpt = waypt_new();
- trkpt->creation_time = timestamp;
- trkpt->microseconds = 0;
+ trkpt->SetCreationTime(timestamp);
trkpt->latitude = latitude;
trkpt->longitude = longitude;
trkpt->altitude = height;
if (global_opts.masked_objective & WPTDATAMASK) {
waypt = waypt_new();
- waypt->creation_time = timestamp;
- waypt->microseconds = 0;
+ waypt->SetCreationTime(timestamp);
waypt->latitude = latitude;
waypt->longitude = longitude;
waypt->altitude = height;
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;
- wpt_tmp->creation_time = mktime(&tm);
+ wpt_tmp->SetCreationTime(mktime(&tm));
} else if (0 == strcmp(ap[0], "retired")) {
if (!strcmp(ap[1], "yes") && noretired) {
xfree(wpt_tmp);
decode_position(buffer + 12, waypt);
waypt->shortname = xstrdup((char*)buffer + 4);
waypt->icon_descr = icon_table[buffer[28]];
- waypt->creation_time = decode_datetime(buffer + 22);
+ waypt->SetCreationTime(decode_datetime(buffer + 22));
return waypt;
}
buffer[10] = 0;
buffer[11] = 0;
encode_position(waypt, buffer + 12);
- encode_datetime(waypt->creation_time, buffer + 22);
+ encode_datetime(waypt->GetCreationTime(), buffer + 22);
buffer[28] = find_icon_from_descr(waypt->icon_descr);
buffer[29] = 0;
buffer[30] = 0x00;
waypoint* waypt = waypt_new();
decode_position(buffer + 12, waypt);
- waypt->creation_time = decode_datetime(buffer + 22);
+ waypt->SetCreationTime(decode_datetime(buffer + 22));
WAYPT_SET(waypt, course, le_read16(buffer + 2));
WAYPT_SET(waypt, speed, KPH_TO_MPS(buffer[29] * 2));
le_write32(buffer + 4, x);
le_write32(buffer + 8, y);
encode_position(waypt, buffer + 12);
- encode_datetime(waypt->creation_time, buffer + 22);
+ encode_datetime(waypt->GetCreationTime(), buffer + 22);
buffer[28] = z;
buffer[29] = MPS_TO_KPH(WAYPT_GET(waypt, speed, 0) / 2);
buffer[30] = 0x5a;
waypt->hdop = ((unsigned char)buffer[0]) * 0.2f;
waypt->sat = buffer[1];
waypt->microseconds = decode_sbp_usec(buffer + 2);
- waypt->creation_time = decode_sbp_datetime_packed(buffer + 4);
+ waypt->SetCreationTime(decode_sbp_datetime_packed(buffer + 4));
decode_sbp_position(buffer + 12, waypt);
WAYPT_SET(waypt, speed, le_read16(buffer + 24) * 0.01f);
WAYPT_SET(waypt, course, le_read16(buffer + 26) * 0.01f);
wpt->creation_time+=SECONDS_PER_DAY;
}
}
- prev = wpt->creation_time;
+ prev = wpt->GetCreationTime();
}
}
}
if (sleepus >= 0) {
gb_sleep(sleepus);
} else {
- long wait_time = wpt->creation_time - last_time;
+ long wait_time = wpt->GetCreationTime() - last_time;
if (wait_time > 0) {
gb_sleep(wait_time * 1000000);
}
}
}
- last_time = wpt->creation_time;
+ last_time = wpt->GetCreationTime();
}
lat = degrees2ddmm(wpt->latitude);
lon = degrees2ddmm(wpt->longitude);
- time_t ct = wpt->creation_time;
+ time_t ct = wpt->GetCreationTime();
tm = gmtime(&ct);
if (tm) {
hms = tm->tm_hour * 10000 + tm->tm_min * 100 + tm->tm_sec;
gbfprintf(fout, " <node id='%d' visible='true' lat='%0.7f' lon='%0.7f'", *id, wpt->latitude, wpt->longitude);
if (wpt->creation_time) {
- char time_string[64];
- xml_fill_in_time(time_string, wpt->creation_time, wpt->microseconds, XML_LONG_TIME);
- gbfprintf(fout, " timestamp='%s'", time_string);
+ QString time_string = wpt->CreationTimeXML();
+ gbfprintf(fout, " timestamp='%s'", qPrintable(time_string));
}
gbfprintf(fout, ">\n");
int len;
ozi_time = atof(str);
- waypointp->creation_time = (ozi_time - DAYS_SINCE_1990) * SECONDS_PER_DAY;
+ waypointp->SetCreationTime((ozi_time - DAYS_SINCE_1990) * SECONDS_PER_DAY);
dot = strchr(str, '.');
/* get number of characters after dot */
{
int latint, lonint;
char tbuf[1024];
- time_t tm = wpt->creation_time;
+ time_t tm = wpt->GetCreationTime();
int32 utmz;
double utme, utmn;
char utmzc;
if (wpt->creation_time != 0) {
tmp = str_pool_get(20);
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = *gmtime(&tt);
strftime(tmp, 20, datefmt, &tm);
buff = ppdb_strcat(buff, tmp, NULL, &len);
tm.tm_year += 100;
}
wpt_tmp = waypt_new();
- wpt_tmp->creation_time = mkgmtime(&tm);
+ wpt_tmp->SetCreationTime(mkgmtime(&tm));
if (read_as_degrees) {
wpt_tmp->longitude = lon;
wpt_tmp->latitude = lat;
double lon,lat;
int icon_token = 0;
char tbuf[1024];
- time_t tm = wpt->creation_time;
+ time_t tm = wpt->GetCreationTime();
lon = degrees2ddmm(wpt->longitude);
lat = degrees2ddmm(wpt->latitude);
lon = degrees2ddmm(wpt->longitude);
lat = degrees2ddmm(wpt->latitude);
- const time_t ct = wpt->creation_time;
+ const time_t ct = wpt->GetCreationTime();
tm = gmtime(&ct);
strftime(tbuf, sizeof(tbuf), "%d-%b-%y %H:%M:%S", tm); /* currently ...%T does nothing under Windows */
wpt->latitude = le_read_float(&bc.latitude);
wpt->longitude = le_read_float(&bc.longitude);
wpt->altitude = FEET_TO_METERS(le_read_float(&bc.altitude));
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
wpt->hdop = le_read_float(&bc.ehpe);
wpt->vdop = le_read_float(&bc.evpe);
wpt->pdop = le_read_float(&bc.espe);
struct tm *tm;
memset(&bc, 0, sizeof(bc));
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = localtime(&tt);
if (wpt->creation_time) {
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = gmtime(&tt);
}
QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
testwpt = (waypoint *)elem;
if (rte_datapoints == 0) {
- uniqueValue = testwpt->creation_time;
+ uniqueValue = testwpt->GetCreationTime();
}
rte_datapoints++;
}
if ((strcmp(psit_current_token, "1") == 0) || (track_head == NULL)) {
track_head = route_head_alloc();
- /* Add a number to the track name. With Garmins, the "first" tracklog is usually ACTIVE LOG
- the second is ACTIVE LOG001 and so on */
+ /* Add a number to the track name. With Garmins, the "first"
+ tracklog is usually ACTIVE LOG
+ the second is ACTIVE LOG001 and so on */
if (trk_num > 0) {
sprintf(tbuf, "%s%03d", trkname, trk_num);
track_head->rte_name = xstrdup(tbuf);
trk_num++;
track_add_head(track_head);
}
-
- thisWaypoint->creation_time = dateTime;
+
+ thisWaypoint->SetCreationTime(dateTime);
track_add_wpt(track_head, thisWaypoint);
-
+
if (gbfeof(psit_file)) {
break;
}
-
+
psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma);
} else {
break;
QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
if (trk_datapoints == 0) {
testwpt = (waypoint *)elem;
- uniqueValue = testwpt->creation_time;
+ uniqueValue = testwpt->GetCreationTime();
}
trk_datapoints++;
}
static void
psit_trackdatapoint_w(gbfile *psit_file, const waypoint *wpt)
{
- time_t t = wpt->creation_time;
+ time_t t = wpt->GetCreationTime();
struct tm *tmTime = gmtime(&t);
gbfprintf(psit_file, "%11.6f,%11.6f,",
route_disp_all(psit_routehdr_w_wrapper, psit_noop, psit_waypoint_w_wrapper);
}
if (global_opts.objective == trkdata) {
- track_disp_all(psit_trackhdr_w_wrapper, psit_noop, psit_trackdatapoint_w_wrapper);
+ track_disp_all(psit_trackhdr_w_wrapper,
+ psit_noop, psit_trackdatapoint_w_wrapper);
}
mkshort_del_handle(&mkshort_handle);
wpt->notes = xstrdup(str);
}
if (((str = inifile_readstr(fin, sect, "Time"))) && *str) {
- wpt->creation_time = EXCEL_TO_TIMET(atof(str));
+ wpt->SetCreationTime(EXCEL_TO_TIMET(atof(str)));
}
if (((str = inifile_readstr(fin, sect, "Bmp"))) && *str) {
unsigned int symbol = atoi(str);
}
}
notes = csv_stringclean(notes, LINE_FEED);
- time = (wpt->creation_time > 0) ? TIMET_TO_EXCEL(wpt->creation_time) : TIMET_TO_EXCEL(gpsbabel_time);
+ time = (wpt->creation_time > 0) ? TIMET_TO_EXCEL(wpt->GetCreationTime()) : TIMET_TO_EXCEL(gpsbabel_time);
name = (char *)wpt->extra_data;
gbfprintf(fout, "[Wp%d]" LINE_FEED
double tlat, tlon, plat, plon, dist;
thisw = (waypoint *)elem;
- timed = thisw->creation_time - prev->creation_time;
+ timed = thisw->GetCreationTime() - prev->GetCreationTime();
/*
* gcdist and heading want radians, not degrees.
tdata->max_cad = (int) thisw->cadence;
}
- if (thisw->creation_time && (thisw->creation_time < tdata->start)) {
- tdata->start = thisw->creation_time;
+ if (thisw->GetCreationTime() && (thisw->GetCreationTime() < tdata->start)) {
+ tdata->start = thisw->GetCreationTime();
}
if (thisw->creation_time > tdata->end) {
- tdata->end = thisw->creation_time;
+ tdata->end = thisw->GetCreationTime();
if (tdata->start == 0) {
tdata->start = tdata->end;
}
if (totaldist > seglen) {
totaldist = seglen;
}
- wpt_tmp->creation_time =
+ wpt_tmp->SetCreationTime(
gpsbabel_time+starttime+
- transittime * totaldist/seglen;
+ transittime * totaldist/seglen);
} else {
- wpt_tmp->creation_time =
- gpsbabel_time+starttime;
+ wpt_tmp->SetCreationTime(gpsbabel_time+starttime);
totaldist = 0;
}
oldlat = lat;
tm.tm_mon = buffer[2] - 1;
tm.tm_year = be_readu16(buffer) - 1900;
- waypt->creation_time = mkgmtime(&tm);
+ waypt->SetCreationTime(mkgmtime(&tm));
waypt->microseconds = (ms % 1000) * 1000;
}
fatal(MYNAME ": Could not parse date string (%s - %s).\n", buf, cx);
}
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
len = strlen(str);
if (global_opts.objective == trkdata) {
struct tm tm;
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = *gmtime(&tt);
strftime(buf + 2, sizeof(buf) - 2, "%d%m%y %H%M%S ", &tm);
} else {
wpt->latitude = lat;
wpt->longitude = lon;
wpt->altitude = alt;
- wpt->creation_time = gpstime_to_timet(st->gps_week, st->gps_sec);
+ wpt->SetCreationTime(gpstime_to_timet(st->gps_week, st->gps_sec));
return wpt;
}
fatal(MYNAME ": relative needs hdop information.\n");
}
// if timestamps exist, distance to interpolated point
- if (wpt1->creation_time != wpt2->creation_time) {
+ if (wpt1->GetCreationTime() != wpt2->GetCreationTime()) {
frac = (double)(wpt3->creation_time - wpt1->creation_time) /
- (wpt2->creation_time - wpt1->creation_time);
+ (wpt2->GetCreationTime() - wpt1->GetCreationTime());
linepart(wpt1->latitude, wpt1->longitude,
wpt2->latitude, wpt2->longitude,
frac, &reslat, &reslon);
case sm_description:
return strcmp(x1->description, x2->description);
case sm_time:
- return x1->creation_time - x2->creation_time;
+ return x1->GetCreationTime() - x2->GetCreationTime();
default:
abort();
return 0; /* Internal caller error. */
void addUSecs(qint64 usecs) const {
this->addMSecs(usecs / 1000);
}
+ int usec() const {
+ return this->time().msec() * 1000;
+ }
// Integer form: YYMMDD
int ymd() const {
const waypoint *wa = *(waypoint **)a;
const waypoint *wb = *(waypoint **)b;
- return wa->creation_time - wb->creation_time;
+ return wa->GetCreationTime() - wb->GetCreationTime();
}
static void
tm.tm_min = min;
tm.tm_sec = sec;
- wpt->creation_time = mklocaltime(&tm);
+ wpt->SetCreationTime(mklocaltime(&tm));
}
if (datum != DATUM_WGS84) {
*dist = 0; /* calc. diffs on 32- and 64-bit hosts */
}
- time = wpt->creation_time - trkpt_out->creation_time;
+ time = wpt->creation_time - trkpt_out->GetCreationTime();
if (time == 0) {
*speed = 0;
} else {
}
if ((all_points == 0) && (this_points == 0)) {
- start_time = wpt->creation_time;
+ start_time = wpt->GetCreationTime();
}
this_points++;
this_distance = this_distance + dist;
if (trkpt_out != NULL) {
- this_time += (wpt->creation_time - trkpt_out->creation_time);
+ this_time += (wpt->GetCreationTime() - trkpt_out->GetCreationTime());
}
trkpt_out = (waypoint *)wpt;
track_points++;
all_track_points++;
- time_t ct = wpt->creation_time;
+ time_t ct = wpt->GetCreationTime();
tm = *localtime(&ct);
strftime(tbuf, sizeof(tbuf), "%d.%m.%Y,%H:%M.%S", &tm);
static void
track_disp_custom_cb(const waypoint *wpt)
{
- if (wpt->creation_time && (wpt->altitude != unknown_alt)) {
- gbfprintf(fout, "%d,%.f\n", (int)(wpt->creation_time - start_time), wpt->altitude);
+ if (wpt->GetCreationTime() && (wpt->altitude != unknown_alt)) {
+ gbfprintf(fout, "%d,%.f\n", (int)(wpt->GetCreationTime() - start_time), wpt->altitude);
}
}
if (wpt != NULL) {
time.tm_year -= 1900;
time.tm_mon--;
- wpt->creation_time = mkgmtime(&time);
+ wpt->SetCreationTime(mkgmtime(&time));
switch (what) {
case STM_WAYPT:
return;
}
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = *gmtime(&tt);
tm.tm_year += 1900;
tm.tm_mon++;
time_t starttime;
time_t endtime;
- if (prevwpp->creation_time >= time_offset)
+ if (prevwpp->GetCreationTime() >= time_offset)
/* if this condition is not true, the waypoint is before the beginning of
* the video and will be ignored
*/
{
- starttime = gps_to_video_time(prevwpp->creation_time);
+ starttime = gps_to_video_time(prevwpp->GetCreationTime());
if (!waypointp) {
endtime = starttime + 1;
} else {
- endtime = gps_to_video_time(waypointp->creation_time);
+ endtime = gps_to_video_time(waypointp->GetCreationTime());
}
gbfprintf(fout, "%d\n", stnum);
stnum++;
} else if WAYPT_HAS(prevwpp, speed) {
gbfprintf(fout, "\n");
}
- subrip_write_time(prevwpp->creation_time);
+ subrip_write_time(prevwpp->GetCreationTime());
gbfprintf(fout, " Lat=%0.5lf Lon=%0.5lf\n",
prevwpp->latitude + .000005,
prevwpp->longitude + .000005);
* way of solving this should be trivial to you :-)
*/
{
- time_offset = sync_time(waypointp->creation_time, opt_videotime);
+ time_offset = sync_time(waypointp->GetCreationTime(), opt_videotime);
}
if (prevwpp) {
{
int latint, lonint;
char tbuf[1024];
- time_t tm = wpt->creation_time;
+ time_t tm = wpt->GetCreationTime();
gbint32 utmz;
double utme, utmn;
char utmzc;
pin = wpt->icon_descr;
} else if (wpt->icon_descr.contains("-unfound")) {
pin = unfoundmarker;
- } else if (wpt->creation_time > current_time() - 3600 * 24 * thresh_days) {
+ } else if (wpt->GetCreationTime() > current_time() - 3600 * 24 * thresh_days) {
pin = newmarker;
} else {
pin = oldmarker;
const waypoint *wa = *(waypoint **)a;
const waypoint *wb = *(waypoint **)b;
- return wa->creation_time - wb->creation_time;
+ return wa->GetCreationTime() - wb->GetCreationTime();
}
static fix_type
i++;
if (i == 1) {
- track_list[track_ct].first_time = wpt->creation_time;
+ track_list[track_ct].first_time = wpt->GetCreationTime();
} else if (i == track->rte_waypt_ct) {
- track_list[track_ct].last_time = wpt->creation_time;
+ track_list[track_ct].last_time = wpt->GetCreationTime();
}
- if ((need_time != 0) && (prev != NULL) && (prev->creation_time > wpt->creation_time)) {
+ if ((need_time != 0) && (prev != NULL) && (prev->GetCreationTime() > wpt->GetCreationTime())) {
if (opt_merge == NULL) {
- char t1[64], t2[64];
- xml_fill_in_time(t1, prev->creation_time, 0, XML_LONG_TIME);
- xml_fill_in_time(t2, wpt->creation_time, 0, XML_LONG_TIME);
- fatal(MYNAME "-init: Track points badly ordered (timestamp %s > %s)!\n", t1, t2);
+ QString t1 = prev->CreationTimeXML();
+ QString t2 = wpt->CreationTimeXML();
+ fatal(MYNAME "-init: Track points badly ordered (timestamp %s > %s)!\n", qPrintable(t1), qPrintable(t2));
}
}
prev = wpt;
for (i = 0; i < track_pts-timeless_pts; i++) {
wpt = buff[i];
- if ((prev == NULL) || (prev->creation_time != wpt->creation_time)) {
+ if ((prev == NULL) || (prev->GetCreationTime() != wpt->GetCreationTime())) {
route_add_wpt(master, wpt);
prev = wpt;
} else {
}
if (interval > 0) {
- double tr_interval = difftime(buff[j]->creation_time,buff[i]->creation_time);
+ double tr_interval = difftime(buff[j]->GetCreationTime(),buff[i]->GetCreationTime());
if (tr_interval <= interval) {
new_track_flag = 0;
}
printf(MYNAME ": splitting new track\n");
#endif
curr = (route_head *) route_head_alloc();
- trackfilter_split_init_rte_name(curr, buff[j]->creation_time);
+ trackfilter_split_init_rte_name(curr, buff[j]->GetCreationTime());
track_add_head(curr);
}
if (curr != NULL) {
RAD(wpt->longitude)));
}
if (opt_speed) {
- if (oldtime != wpt->creation_time) {
+ if (oldtime != wpt->GetCreationTime()) {
WAYPT_SET(wpt, speed, radtometers(gcdist(
RAD(oldlat), RAD(oldlon),
RAD(wpt->latitude),
RAD(wpt->longitude))) /
- labs(wpt->creation_time-oldtime));
+ labs(wpt->GetCreationTime()-oldtime));
} else {
WAYPT_UNSET(wpt, speed);
}
}
oldlat = wpt->latitude;
oldlon = wpt->longitude;
- oldtime = wpt->creation_time;
+ oldtime = wpt->GetCreationTime();
}
}
}
QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
waypoint *wpt = (waypoint *)elem;
if (wpt->creation_time > 0) {
- inside = ((wpt->creation_time >= start) && (wpt->creation_time <= stop));
+ inside = ((wpt->GetCreationTime() >= start) && (wpt->GetCreationTime() <= stop));
}
// If the time is mangled so horribly that it's
// negative, toss it.
ymd.tm_mon--;
if (opt_utc) {
- wpt->creation_time = mkgmtime(&ymd);
+ wpt->SetCreationTime(mkgmtime(&ymd));
} else {
- wpt->creation_time = mklocaltime(&ymd);
+ wpt->SetCreationTime(mklocaltime(&ymd));
}
} else if (ymd.tm_hour || ymd.tm_min || ymd.tm_sec) {
if (opt_utc) {
- wpt->creation_time = mkgmtime(&ymd);
+ wpt->SetCreationTime(mkgmtime(&ymd));
} else {
- wpt->creation_time = mklocaltime(&ymd);
+ wpt->SetCreationTime(mklocaltime(&ymd));
}
}
if (wpt->creation_time >= SECONDS_PER_DAY) {
struct tm tm;
char buf[32];
- time_t time = wpt->creation_time;
+ time_t time = wpt->GetCreationTime();
if (opt_utc) {
time += atoi(opt_utc) * SECONDS_PER_HOUR;
tm = *gmtime(&time);
} else {
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = *localtime(&tt);
}
tm.tm_year += 1900;
if (wpt->creation_time != 0) {
struct tm tm;
char buf[32], msec[12];
- time_t time = wpt->creation_time;
+ time_t time = wpt->GetCreationTime();
if (opt_utc) {
time += atoi(opt_utc) * SECONDS_PER_HOUR;
tm = *gmtime(&time);
} else {
- const time_t tt = wpt->creation_time;
+ const time_t tt = wpt->GetCreationTime();
tm = *localtime(&tt);
}
snprintf(buf, sizeof(buf), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
int date, time;
date = atoi(line.bas.common.date);
time = atoi(line.bas.common.time);
- wpt->creation_time = bintime2utc(date, time);
+ wpt->SetCreationTime(bintime2utc(date, time));
}
wpt->speed = KPH_TO_MPS(atoi(line.bas.common.speed));
tmStruct.tm_sec =(int)floor(seconds);
tmStruct.tm_isdst =-1;
- wpt_tmp->creation_time = mkgmtime(&tmStruct);
- wpt_tmp->microseconds = fmod(1000000*seconds+0.5,1000000);
+ wpt_tmp->SetCreationTime(mkgmtime(&tmStruct),
+ fmod(1000000*seconds+0.5,1000000));
wpt_tmp->shortname = (char*) xcalloc(16,1);
snprintf(wpt_tmp->shortname, 15 , "WP%04d", ++serial);
WriteDouble(&workbuffer[position], waypointp->altitude);
}
position += sizeof(double);
- QDate date(waypointp->creation_time.date());
- QTime time(waypointp->creation_time.time());
+ QDate date(waypointp->GetCreationTime().date());
+ QTime time(waypointp->GetCreationTime().time());
workbuffer[position++] = date.year()-100;
workbuffer[position++] = date.month();
workbuffer[position++] = date.day();
tmStruct.tm_sec = scaled_sec / vitovtt_secondscale;
microseconds = (scaled_sec % vitovtt_secondscale) / vitovtt_microsecondscale;
- wpt_tmp->creation_time = mkgmtime(&tmStruct);
- wpt_tmp->microseconds = microseconds;
+ wpt_tmp->SetCreationTime(mkgmtime(&tmStruct), microseconds);
/*
* TODO: interpret speed, course, status
waypt->hdop = hdop_raw / (double) 8;
waypt->vdop = vdop_raw / (double) 8;
- waypt->creation_time = mkgmtime(&tm);
+ waypt->SetCreationTime(mkgmtime(&tm));
track_add_wpt(track_head, waypt);
}
{
return (wpt->gc_data == &empty_gc_data);
}
+
+QString
+waypoint::CreationTimeXML() const
+{
+ if (creation_time == 0) {
+ return NULL;
+ }
+
+ QDateTime dt = QDateTime::fromTime_t(creation_time);
+ dt = dt.addMSecs(MICRO_TO_MILLI(microseconds));
+ dt = dt.toUTC();
+
+ const char* format = "yyyy-MM-ddTHH:mm:ssZ";
+ if (dt.time().msec()) {
+ format = "yyyy-MM-ddTHH:mm:ss.zzzZ";
+ }
+
+ return dt.toString(format);
+}
wpt->latitude = lat;;
wpt->longitude = lon;
wpt->altitude = alt;
- wpt->creation_time = tim;
+ wpt->SetCreationTime(tim);
wpt->shortname = xstrdup(wp_name);
return wpt;
}
}
- wpt_tmp->creation_time = ap_first;
+ wpt_tmp->SetCreationTime(ap_first);
waypt_add(wpt_tmp);
wpt = waypt_new();
wpt->latitude = latitude / 1.0e7;
wpt->longitude = longitude / 1.0e7;
- wpt->creation_time = wintec_date_to_time(date);
+ wpt->SetCreationTime(wintec_date_to_time(date));
// The unit of altitude isn't clear and we have a lot of
// samples with wildly negative values, so ignore those for now.
wpt->altitude = alt;
#include "defs.h"
#include "xmlgeneric.h"
#include "cet_util.h"
+#include <QtCore/QDebug>
#define DEBUG_TAG 0
#if DEBUG_TAG
}
void
-xml_fill_in_time(char *time_string, const time_t timep, int microseconds, int long_or_short)
+xml_fill_in_time(char *time_string, const time_t timep, int long_or_short)
{
- struct tm *tm = gmtime(&timep);
- const char *format;
- int n;
-
- if (!tm) {
- *time_string = 0;
- return;
- }
+ QDateTime dt = QDateTime::fromTime_t(timep);
+ dt = dt.toUTC();
+ const char* format;
if (long_or_short == XML_LONG_TIME) {
- format = "%02d-%02d-%02dT%02d:%02d:%02d";
+ format = "yyyy-MM-ddTHH:mm:ssZ";
+ if (dt.time().msec()) {
+fprintf(stderr, "this should not be possible");
+abort();
+ format = "yyyy-MM-ddTHH:mm:ss.zzzZ";
+ }
} else {
- format = "%02d%02d%02dT%02d%02d%02d";
- }
- n = sprintf(time_string, format,
- tm->tm_year+1900,
- tm->tm_mon+1,
- tm->tm_mday,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
- if (microseconds) {
- n += sprintf(time_string + n, ".%03d", microseconds / 1000);
+ format = "yyyyMMddTHHmmssZ";
}
- time_string[n++] = 'Z';
- time_string[n++] = '\0';
-
+ strcpy(time_string, qPrintable(dt.toString(format)));
}
void
xml_write_time(gbfile *ofd, const time_t timep, int microseconds, const char *elname)
{
char time_string[64];
- xml_fill_in_time(time_string, timep, microseconds, XML_LONG_TIME);
+ xml_fill_in_time(time_string, timep, XML_LONG_TIME);
if (time_string[0]) {
gbfprintf(ofd, "<%s>%s</%s>\n",
elname,
void write_optional_xml_entity(gbfile* ofd, const QString& indent,
const QString& tag, const QString& value);
void xml_write_time(gbfile* ofd, const time_t timep, int microseconds, const char* elname);
-void xml_fill_in_time(char* time_string, const time_t timep, int microseconds,
- int long_or_short);
+void xml_fill_in_time(char* time_string, const time_t timep, int long_or_short);
void write_xml_header(gbfile* ofd);
void xml_ignore_tags(const char** taglist);
static void
xol_write_time(const waypoint *wpt)
{
- char time_string[64];
-
- xml_fill_in_time(time_string, wpt->creation_time, wpt->microseconds, XML_LONG_TIME);
- if (time_string[0]) {
- gbfprintf(fout, " timestamp=\"%s\"", time_string);
+ QString time_string = wpt->CreationTimeXML();
+ if (!time_string.isEmpty()) {
+ gbfprintf(fout, " timestamp=\"%s\"", qPrintable(time_string));
}
}